package com.xiaoKe.zhonghzu.global.view;

import android.content.Context;
import android.util.AttributeSet;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;


import com.xiaoKe.zhonghzu.global.bean.GeneralData;
import com.xiaoKe.zhonghzu.ui.onClick.OnClickListenerPositionInt;

import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

/**
 * @ProjectName : yg119
 * @Author : Shijingna
 * @Time : 2024/9/4 13:57
 * @Description : 文件描述
 */
public class ViewRecyclerView extends RecyclerView {
    List<GeneralData> list = new ArrayList<>();

    public ViewRecyclerView(@NonNull @NotNull Context context) {
        super(context);
    }

    public ViewRecyclerView(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public ViewRecyclerView(@NonNull @NotNull Context context, @Nullable @org.jetbrains.annotations.Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    ButtonAdapter buttonAdapter;

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        setLayoutManager(new LinearLayoutManager(getContext(), RecyclerView.HORIZONTAL, false));

    }

    public void into(List<GeneralData> list, OnClickListenerPositionInt onClickListenerPositionInt) {
        this.list = list;
        buttonAdapter = new ButtonAdapter(list);
        setAdapter(buttonAdapter);
        buttonAdapter.setOnClickListenerPositionInt(new OnClickListenerPositionInt() {
            @Override
            public void onItemClick(int item) {
                onClickListenerPositionInt.onItemClick(item);

            }
        });
    }

    public void intoIndex(int index) {
        buttonAdapter.setIsPosition(index);
    }

    public void intoIndexNex( List<Integer> indexList ) {
        buttonAdapter.setIsPositionNex(indexList);
    }
}
